#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	struct student {
		int grade;
		string name;
	} aa[105];
	
	for (int i=1;i<=n;i++)
	{
		cin>>aa[i].grade;
		cin>>aa[i].name;
	}
	
	int maxx=-1,temp=0;
	for (int i=1;i<=n;i++) if (aa[i].grade>maxx) 
	{
		maxx=aa[i].grade;
		temp=i;
	}
	
	cout<<aa[temp].name<<endl;
	
	return 0;
}